﻿// See https://aka.ms/new-console-template for more information
using Microsoft.Extensions.Logging;
using mqtt.client.test;
using mqtt.client.test.Mqtt;
using mqtt.client.test.Mqtt.Connect;
using mqtt.client.test.Mqtt.Subscribe;
using mqtt.client.test.Options;


Console.WriteLine("Hello, World!");

//MyMqttClient client2 = new MyMqttClient("127.0.0.1", 1883);
//client2.Conect();
//client.Public();
//client2.Subscribe();

//Console.WriteLine();
                       
MqttClient client =  new MqttClient("127.0.0.1", 1883);
client.ReceiveMessageAction = (message) => {
    Console.WriteLine("ReceiveMessageAction");
    Console.WriteLine(message.Result);
};



 await client.Connect(new ConnectOption("test1")
{
  //  UserName = "admin",
  //  Password = "admin"
});



//await client.Subscribe(new SubscribeOption("a")
//{
  //  QoS = Qos.Qos2
//});

//await client.Connack();
await client.Publish(new PublishOption("testTopic", "test")
{
    QoS = Qos.Qos0
});

//await client.Subscribe(new SubscribeOption("abc"));
//await client.PingReq();
//await client.Suback();

Console.ReadLine();